<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<aside class="main-sidebar">
    <section class="sidebar">
      <ul class="sidebar-menu">
      </ul>
    </section>
  </aside>
<script>
 $(function(){
	 var url = contextPath + "/corp.do?method=menu&"+new Date().getTime();
	 var activeDom;
	 $.get(url,function(data){
		  $.each(data,function(){
			  var aHtml = ' id="ma_'+this.id+'" menu-smallName="'+(this.smallName||'')+'" menu-name="'+this.name+'" ';
			  if(this.url){
				  aHtml += ' url="'+this.url+'" ';
				  if(this.active){
					  activeDom = this.id;
				  }
			  }
			  var $li = $('<li class="treeview '+this.active+'"><a '+aHtml+' href="javascript:;"><i class="'+this.menuIcon+'"></i> '+
					  '<span>'+this.name+'</span><i class="fa fa-angle-left pull-right"></i></a>'+
					  ((this.children && this.children.length > 0)?'<ul class="treeview-menu" '+(this.active?'':'style="display: none;"')+'></ul>':'')+'</li>');
			  $(".sidebar-menu").append($li);
			  renderSubMenu(this.children,$li);
			  if(activeDom){
				  openTab($("#ma_"+activeDom));
			  }
	 	});
	  },"json");
	 
	 function renderSubMenu(data,$li){
		 if(data && data.length > 0){
			 $.each(data,function(){
				 var aHtml = ' id="ma_'+this.id+'" menu-smallName="'+(this.smallName||'')+'" menu-name="'+this.name+'" ';
				  if(this.url){
					  aHtml += ' url="'+this.url+'" ';
					  if(this.active){
						  activeDom = this.id;
					  }
				  }
				 var $cli = $('<li class="'+this.active+'"><a '+aHtml+' href="javascript:;">'+
				 '<i class="fa fa-circle-o"></i> '+this.name+'</a>'+
				 ((this.children && this.children.length > 0)?'<ul class="treeview-menu" style="display: none;"></ul>':'')+'</li>');
				 $($li.find("ul")[0]).append($cli)
				 renderSubMenu(this.children,$cli);
			 });
		 }
	 }
 });
 </script>